package org.dormi.learn.product.domain.material.entity;

import lombok.Getter;
import org.dormi.learn.pojo.ExtensibleTenantEO;
import org.dormi.learn.primitive.Measure;
import org.dormi.learn.primitive.MeasureUnitEnum;
import org.dormi.learn.utils.Assert;
import org.dormi.learn.utils.TrackingUtils;

/**
 * 物料
 *
 * @author : dormi330
 * @version : 1.0
 */
@Getter
public class Material extends ExtensibleTenantEO {

    private Long id;
    /** 内部物料编码 */
    private String code;
    /** 条码 */
    private String barCode;
    /** 外部编码 */
    private String extCode;
    private String name;
    private String categoryCode;
    /** 实体类型 */
    private PhysicalForm physicalForm;
    private String brandCode;


    /** 物流信息 重量 长宽高 */
    private MaterialLogistics logistics;
    /** 有效期时长 */
    private Measure validityTime;
    /** 基本存储计量单位: 最小单位 */
    private MeasureUnitEnum minSKU;
    private TrackingTypeEnum trackingType;
    private Boolean canBeSold = false;
    private Boolean canBePurchased = false;

    // ======== feature ========
    /** 别名, 易于记忆, 允许修改, 重复 */
    private String alias;
    /** 短编码, 易于记忆 */
    private String shortCode;
    /** 自定义分组1,2 */
    private String group1;
    private String group2;


    /* === internal biz code === */
    /* === internal biz code === */
    /* === internal biz code === */

    /** 完整性校验 */
    public void checkIntegrity() {
        TrackingUtils.debugTrace();
        // not null check
        Assert.isNotNull(categoryCode, "不能为null: categoryCode");
        Assert.isNotNull(name, "不能为null: name");
        Assert.isNotNull(trackingType, "不能为null: trackingType");
    }

    /* === setter === */
    /* === setter === */
    /* === setter === */

    public void setId(Long id) {
        this.id = id;
        _markDirty();
    }

    public void setCode(String code) {
        this.code = code;
        _markDirty();
    }

    public void setBarCode(String barCode) {
        this.barCode = barCode;
        _markDirty();
    }

    public void setExtCode(String extCode) {
        this.extCode = extCode;
        _markDirty();
    }

    public void setName(String name) {
        this.name = name;
        _markDirty();
    }

    public void setCategoryCode(String categoryCode) {
        this.categoryCode = categoryCode;
        _markDirty();
    }

    public void setPhysicalForm(PhysicalForm physicalForm) {
        this.physicalForm = physicalForm;
        _markDirty();
    }

    public void setBrandCode(String brandCode) {
        this.brandCode = brandCode;
        _markDirty();
    }

    public void setLogistics(MaterialLogistics logistics) {
        this.logistics = logistics;
        _markDirty();
    }

    public void setValidityTime(Measure validityTime) {
        this.validityTime = validityTime;
        _markDirty();
    }

    public void setMinSKU(MeasureUnitEnum minSKU) {
        this.minSKU = minSKU;
        _markDirty();
    }

    public void setTrackingType(TrackingTypeEnum trackingType) {
        this.trackingType = trackingType;
        _markDirty();
    }

    public void setCanBeSold(Boolean canBeSold) {
        this.canBeSold = canBeSold;
        _markDirty();
    }

    public void setCanBePurchased(Boolean canBePurchased) {
        this.canBePurchased = canBePurchased;
        _markDirty();
    }

    public void setAlias(String alias) {
        this.alias = alias;
        _markDirty();
    }

    public void setShortCode(String shortCode) {
        this.shortCode = shortCode;
        _markDirty();
    }

    public void setGroup1(String group1) {
        this.group1 = group1;
        _markDirty();
    }

    public void setGroup2(String group2) {
        this.group2 = group2;
        _markDirty();
    }
}
